package easystudy.admin;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import easystudy.dao.BoardDao;

@Controller
public class DeleteOnBoardController {
	
	private BoardDao boardDao;
	
	public void setBoardDao(BoardDao boardDao){
		this.boardDao = boardDao;
	}
	
	@RequestMapping(value="/ad_delete_onBoard.ad")
	protected ModelAndView doDeleteProcess(@RequestParam("board_num")int board_num,
			@RequestParam("category")int category, @RequestParam("page")int page){
		boardDao.deleteBoard(board_num);
		
		String path = null;
		
		switch(category){
		case 1 : path = "ja_list.ja?page="+page; break;
		case 2 : path = "db_list.db?page="+page;break;
		case 3 : path = "js_list.bo?page="+page;break;
		case 4 : path = "fr_list.fr?page="+page;break;
		default : path = "no_list.no?page="+page;break;
		}
			
		return new ModelAndView(new RedirectView(path));
	}

}
